home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / lib / ttyline / lookuptty.c < prev    next >
C/C++ Source or Header  |  1996-07-22  |  602b  |  28 lines

  1.  
  2. #include "ttyline.p"
  3.  
  4. int lookup_tty(char *line)
  5. {
  6.     int
  7.         index;
  8.     char
  9.         buffer[10];
  10.  
  11.     if (!line)
  12.         return (-1);
  13.  
  14.     if (isdigit(*line))                     /* digit requested */
  15.     {
  16.         sprintf(buffer, "ttyS%s", line);    /* make it a ttyS line */
  17.         line = buffer;
  18.     }
  19.     
  20.     for (index = n_lines; index--; )        /* walk all lines */
  21.     {
  22.         if (!strcmp(ttyline[index], line)) /* match found ? */
  23.             break;                          /* then break the loop */
  24.     }
  25.     
  26.     return (index);                         /* return the index */
  27. }
  28.